<?php // index.php index page

// check for non-installation
if(!is_file('./config/config.php')){
	header ("Location:  http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/install/index.php");
	exit();
}

require_once('./inc/inc.common.php');
$tmpl 		= new mvTemplate();
$tmpl->page_title(mvSettings::get('kbname') . ' KB');

$sql = "SELECT FileID, Title, Views, Articledata, DATE_FORMAT(Submitdate, '%e %M, %Y') AS date  FROM  articles  WHERE Approved='Y' AND ParentID = 0 ORDER by Views DESC LIMIT " . mvSettings::get('db_max_rec');
$query = $GLOBALS['db']->prepare_execute($sql);
$tmpl->assign('top_views', $query->fetchAll());

$sql = "SELECT FileID, Title, Articledata, DATE_FORMAT(Submitdate, '%e %M, %Y') AS date FROM articles WHERE Approved='Y' AND ParentID =0 ORDER by FileID DESC LIMIT " . mvSettings::get('db_max_rec');
$query = $GLOBALS['db']->prepare_execute($sql);
$tmpl->assign('top_created', $query->fetchAll());

$sql = "SELECT FileID, Title, Views, Articledata, DATE_FORMAT(Submitdate, '%e %M, %Y') AS date FROM articles WHERE Approved='Y' AND ParentID =0 ORDER by RatingTotal/RatedTotal DESC LIMIT " . mvSettings::get('db_max_rec');
$query = $GLOBALS['db']->prepare_execute($sql);
$tmpl->assign('top_rated', $query->fetchAll());

$tmpl->page_display('home.tpl');
?>